home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / NetscapeExecutionContextParser.java < prev    next >
Text File  |  1998-09-27  |  2KB  |  85 lines

  1. package com.symantec.itools.lang;
  2.  
  3.  
  4. import java.io.BufferedReader;
  5. import java.io.StringReader;
  6.  
  7.  
  8. /**
  9.  * @author Symantec Internet Tools Division
  10.  * @version 1.0
  11.  * @since VCafe 3.0
  12.  */
  13.  
  14. public class NetscapeExecutionContextParser
  15.     extends ExecutionContextParser
  16. {
  17.     protected NetscapeExecutionContextParser()
  18.     {
  19.     }
  20.  
  21.     /**
  22.      * @param stackTrace TODO
  23.      * @param level TODO
  24.      * @since VCafe 3.0
  25.      */
  26.     
  27.     public void parse(String stackTrace, int level)
  28.     {
  29.         BufferedReader reader;
  30.  
  31.         reader = new BufferedReader(new StringReader(stackTrace));
  32.         
  33.         // skip past
  34.         //    at com.symantec.itools.lang.Debug.getStackTrace(Debug.java:xxx)
  35.         //    at com.symantec.itools.lang.Debug.getExecutionContext(Debug.java:xxx)
  36.         level += 2;
  37.         
  38.         try   
  39.         {
  40.             String str;
  41.             int    i;
  42.             int    j;
  43.  
  44.             // get rid of "Throwable"
  45.             if(reader.readLine() == null)
  46.             {
  47.                 return;
  48.             }
  49.  
  50.             // remove unwanted lines
  51.             // if the JIT is on we will return at this point
  52.             for(i = 0; i < level; i++)
  53.             {
  54.                 if(reader.readLine() == null)
  55.                 {
  56.                     return;
  57.                 }
  58.             }
  59.  
  60.             // get rid of class the "at " & ")"
  61.             str = reader.readLine().trim();
  62.             str = str.substring(3, str.length() - 1);
  63.  
  64.             // get the info - : tells us where the line number is
  65.             j = str.indexOf(':');
  66.             i = str.indexOf('(');
  67.             
  68.             // is the JIT on?
  69.             if(j != -1)
  70.             {
  71.                 // if it is on we can get the line number & the file
  72.                 line = new Integer(str.substring(j + 1)).intValue();
  73.                 file = str.substring(i + 1, j);
  74.             }
  75.             
  76.             str    = str.substring(0, i);
  77.             i      = str.lastIndexOf('.');
  78.             method = str.substring(i + 1);
  79.             clazz  = str.substring(0, i);
  80.         }
  81.         catch(Throwable ex)
  82.         {
  83.         }
  84.     }
  85. }